<?php
//生成时间2022-08-15 09:17
class emp{
    static private $s_no=NULL;//工号
    static public function Set_s_no($s_no){
        if(strlen($s_no)<1 || strlen($s_no)>20){
            return 101;
        }
        if(!preg_match("/^([A-Z]|[a-z]|\d)(\d{4,17}|(\d{4,17}[A-Z]\d{0,4}))|(^\d{18}$)|(^\d{17}(\d|X|x)$)$/",$s_no)){
            return 103;
        }
        self::$s_no=$s_no;
        return 1;
    }
    static private $s_name=NULL;//姓名
    static public function Set_s_name($s_name){
        if(strlen($s_name)<0 || strlen($s_name)>90){
            return 101;
        }
        self::$s_name=$s_name;
        return 1;
    }
    static public function Add(){
        $sql="insert into g2_emp_t(";
        $sql.=self::$s_no!=NULL?"s_no,":'';
        $sql.=self::$s_name!=NULL?"s_name,":'';
        $sql=trim($sql,',');
        $sql.=") values (";
        $sql.=self::$s_no!=NULL?"'".self::$s_no."',":'';
        $sql.=self::$s_name!=NULL?"'".self::$s_name."',":'';
        $sql=trim($sql,',');
        $sql.=");";
        return $sql;
    }
    static public function Edit(){
        $sql="update g2_emp_t set ";
        $sql.=self::$s_name!=NULL?"s_name='".self::$s_name."',":'';
        $sql=trim($sql,',');
        $sql.=" where 1=1";
        $sql.=self::$s_no!=NULL?" and s_no='".self::$s_no."'":'';
        return $sql.';';
    }
    static public function Delete(){
        $sql="delete from g2_emp_t";
        $sql.=" where 1=1";
        $sql.=self::$s_no!=NULL?" and s_no='".self::$s_no."'":'';
        return $sql.';';
    }
    static public function Select(){
        $sql="select * from g2_emp_t";
        return $sql;
    }
}
?>